<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta charset="utf-8">
  <title> Media Html5 </title>
  <meta name="generator" content="editplus" />
  <meta name="author" content="" />
  <meta name="keywords" content="" />
  <meta name="description" content="" />
 </head>

 <body>
  
 <video id="video_test" width="420" style="background:black"></video>

<script type="text/javascript">

var video = document.getElementById("video_test");


//检测兼容性
var console = console || {log:function(){}};
navigator.getUserMedia= navigator.getUserMedia|| navigator.webkitGetUserMedia|| navigator.mozGetUserMedia|| navigator.msGetUserMedia;
window.URL = window.URL|| window.webkitURL|| window.mozURL|| window.msURL;



function start(){
	if(navigator.getUserMedia){
		// Call the getUserMedia method here
		navigator.getUserMedia({video:true,audio:true}, successCallback, errorCallback);
	}else{    
		console.log('Native device media streaming (getUserMedia) not supported in this browser.');
		// Display a friendly "sorry" message to the user.
		alert('Native device media streaming (getUserMedia) not supported in this browser.')
	}
}

function successCallback(stream) {
	console.log(stream);
	console.log(stream.getAudioTracks());
	console.log(stream.getVideoTracks());
	if (video.mozSrcObject !== undefined) {
        video.mozSrcObject = stream;
    } else {
        video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
    };
    video.play();
}

function errorCallback(err){
	console.log(err);
}

start();

</script> 



 </body>
</html>
